
local list = {}
local index = 0
for a=1,20 do
    local icon = class.panel.create('1',1280,0,32,32)
    function icon:move_animation_finish()
        icon:hide()
    end
    icon:hide()
    list[a] = icon
end


local paths = {
    ['金币'] = [[图标\金币.blp]],
    ['木材'] = [[图标\木材.blp]],
    ['杀敌'] = [[图标\杀敌.blp]],
}

ac.game:event '动画-获得资源'(function(_,player,name,slotid)
    local x,y,z = 0,0,0
    local button = ac.console.itemdetail[slotid]
    if type(slotid)=='table' then
        x = slotid.x
        y = slotid.y
        z = slotid:get_height()
    elseif button then
        x,y = button:get_real_position()
        local r = math.random(360)
        local s = math.random(60)
        x = x + s * math.cos(r)
        y = y + s * math.sin(r)
    end
    if player:is_self() then
        if type(slotid)=='table' then
            x,y = ac.frame.w2s(x,y,z)
        end
        index = index%20 + 1
        local ui = list[index]
        local x2 = 0
        if name=='金币' then
            x2 = 1280
        end
        if name=='木材' then
            x2 = 1480
        end
        if name=='杀敌' then
            x2 = 1680
        end
        ui:set_real_position(x,y)
        ui:set_normal_image(paths[name])
        ui:move_animation({x2,0},1.5)
        ui:show()
    end
end)
